package in.co.codedoc.sql.mapping;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;

import in.co.codedoc.sql.DBInputColumnMap;
import in.co.codedoc.sql.SQLStatement;

public class BooleanBooleanInputColumnMap extends DBInputColumnMap
{
	public BooleanBooleanInputColumnMap(boolean v)
	{
		this.v = v;
	}
	
	@Override
	public void SetParameter(int index, PreparedStatement ps)
		throws SQLException
	{
		if(Logger.logger.isDebugEnabled())
		{
			if(index > 1)
			{
				SQLStatement.GetDebugStringBuffer().append(",");
			}
		}
		
		if(IsNull())
		{
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append("<NULL>");
			}
			
			ps.setNull(index, Types.BOOLEAN);
		}
		else
		{
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append(v);
			}
			
			ps.setBoolean(index, v);
		}
	}
	
	private boolean v;
}
